#include "stdio.h"
#include "stdint.h"
#include "string.h"
#include "stdlib.h"
#include "math.h"
#include "../src/struct_util.h"
#include "hexstring.h"

int main(int argc, char const *argv[])
{
    int res = 0;
    const uint32_t c32[2] = {0x01020304,
                             0x05060708};
    const uint16_t c16[4] = {0x0102, 0x0304, 0x0506, 0x0708};
    uint8_t b32data[] = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08};
    uint8_t l32data[] = {0x04, 0x03, 0x02, 0x01, 0x08, 0x07, 0x06, 0x05};
    uint8_t b16data[] = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08};
    uint8_t l16data[] = {0x02, 0x01, 0x04, 0x03, 0x06, 0x05, 0x08, 0x07};

    be32toh_inplace(b32data, 2);

    if (0 == memcmp(c32, b32data, sizeof(c32)))
    {
        res |= 1;
    }
    le32toh_inplace(l32data, 2);

    if (0 == memcmp(c32, l32data, sizeof(c32)))
    {
        res |= 2;
    }
    be16toh_inplace(b16data, 4);
    if (0 == memcmp(c16, b16data, sizeof(c16)))
    {
        res |= 4;
    }
    le16toh_inplace(l16data, 4);

    if (0 == memcmp(c16, l16data, sizeof(c16)))
    {
        res |= 8;
    }

    return res != 0x0f;
}
